#ifndef __CLIENT__H__
#define __CLIENT__H__

	#include <netinet/in.h>
	
	#define MESSAGE_NAME_SIZE 30
	#define MESSAGE_TEXT_SIZE 1024

	using namespace std;

	enum message_type
	{
		MSG_TYPE_REGIST,
		MSG_TYPE_LOGIN,
		MSG_TYPE_LOGOUT,
		MSG_TYPE_MESSAGE
	};
	struct message_t
	{
		enum message_type type;
		char name[MESSAGE_TEXT_SIZE];
		char text[MESSAGE_TEXT_SIZE];
	};

	class client
	{
		public:
			client(const char *ip,const char *port);
			~client();

			int setUser(const char *_name,const char *_password);
			int setMode(enum message_type type)
			{
				s_message.type = type;
			}
			int start(void);
		protected:
			int my_send(struct sockaddr_in &targetAddr);
			int my_receive(struct sockaddr_in &targetAddr);

			struct message_t r_message,s_message;
			struct sockaddr_in serveraddr,clientaddr;
			int sockfd;
		private:
			virtual int child_process(void);
			virtual int parent_process(void);

	};
	


#endif
